<html>
  <head>
    <meta charset="utf-8"> 
    <title>美业红</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css">
    <script type='text/javascript' src='/public/js/jquery-1.11.2.min.js'></script>
    <script type="text/javascript" src='/public/js/jquery.validate.js'></script>  
    <link rel="stylesheet" href="/public/css/admin.css">
  </head>
  <body>

    <nav class="navbar navbar-default" role="navigation">
      <div class="container-fluid"> 
      <div class="navbar-header">
          <a class="navbar-brand" href="#">美业红</a>
      </div>
      <div>
          <form class="navbar-form navbar-left" role="search" >
          <div class="form-group">
              <input style='width:200px' type="text" class="form-control" placeholder="请输入门店名称" name='store_name' id='store_name' value="<?php echo $store_name; ?>" >
          </div>
          <a href='#' onclick="_search();" class="btn btn-default">查询</a>
          </form>
      </div>
      </div>
    </nav>
      <div class="table-responsive">
            <table  class="table table-striped table-bordered" style=" margin-top:3rem;"  >
                <thead>
                    <tr>
                        <th width="20%">门店名称</th>
                        <th width="30%">地址</th>
                        <th width="10%">负责人</th>
                        <th width="10%">电话</th>
                        <th width="20%">插入时间</th>
                        <th width="10%">授权状态</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach($list as $v){  ?>
                    <tr>
                        <td><?php echo $v['name'];?></td>
                        <td><?php echo $v['address'];?></td>
                        <td><?php echo $v['person_charge'];?></td>
                        <td><?php echo $v['tel'];?></td>
                        <td><?php echo date('Y-m-d H:i:s',$v['create_time']);?></td>
                        <td><?php echo $v['status']==0?'<a onclick="dispose(this);" _id="'.$v['id'].'">未授权</a>':'<a onclick="dispose(this,true);" _id="'.$v['id'].'">已授权';?></td>
                    </tr>
                    <?php }  ?>
                    <tr><td  colspan=6 align='center'><?php echo $page;?></td><tr>
                </tbody>
            </table>
        </div>
      <script type='text/javascript'>
              function _search(){
                  var store_name = $('#store_name').val();
                  window.location.href='/admin/store?store_name='+store_name;
              }
              
              function dispose(obj,bool){
                if(!confirm("确认操作？")){
                    return;
                }
                var str = '已授权';
                var url='/admin/store/dispose?id=';
                var id = $(obj).attr('_id');
                url = url + id;
                if(bool == true){
                    url = url + '&status=display';
                    str = '未授权';
                }
                $.ajax({
                    url: url,
                    async: true, 
                    success: function (msg) {
                        if(msg == 'true'){
                            alert('处理成功');
                            $(obj).html(str);
                            if(bool){
                                $(obj).attr('onclick','dispose(this);');
                            }else{
                                $(obj).attr('onclick','dispose(this,true);');
                            }
                        }else{
                            alert('处理失败');
                        }
                    }
                });
            }
          </script>